import * as bm from "/js/baseModule.js";

export class Module extends bm.baseModule {
    constructor(view) {
        super(view);
        let that = this;
        //套餐详情渲染
        this._Invitation = '';
        let mypack = globalData.pack;
        let userinfo = globalData.user;
        let province = globalData.province;
        that._Invitation = new Vue({
            el: '.invitation-list',
            data: {
                pack: mypack,
                user: userinfo,
                province: province,
                vipCnt: globalData.supplier_cnt,
                levelNum: '1',
                friendLists: [],
                friendNum: 0,
            },
            methods: {
                updateTime: function (startTime) {
                    return funs.countTimeGap(startTime)
                },
            }
        });
        if (globalData.entryPage == "user/VipLevel/Invitation") {
            let arr = [];
            api.getInviteList(function (json) {
                if (json) {
                    arr = json.not_bind_data.concat(json.data);
                    arr.sort(function sortNumber(a, b) {
                        return b.invite_time - a.invite_time;
                    });
                    that._Invitation.friendNum = arr.length;
                    that._Invitation.friendLists = arr;
                }
            }, function (error) {
                funs.tip(error.msg, "", "fail");
            });
        }
    }
    /*生成邀请卡*/
    _evt_createInvitation() {
        //如果是游客点击了需要登录的选项
        if (globalData.user.user_type == 0) {
            $(document).trigger('openLoginModal');
            return
        }
        api.createInvitCard(function (json) {
        }, function (error) {
            funs.tip(error.msg, "", "fail");
        });
        funs.openModal('modules/user/InviteCardModal.js',function (mod) {
            console.log('....');
        })
    }
    setInvitationList(json) {
        if (json) {
            this._Invitation.friendNum = json.cnt;
            this._Invitation.friendLists = json.data;
        }

    }
   

}
